package day6Exer;

/*
* 抽象父类 图形
* */
public abstract class Shape {

    public abstract double getArea();
}
/*
* 子类 圆形
* */
class Circle extends Shape{

    //属性半径
    private double radius;
    @Override
    public double getArea() {
        return Math.PI*Math.pow(radius,2);
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }
}

/*
* 子类 矩形
* */
class Rectangle extends Shape{
    private double width;

    private double height;

    @Override
    public double getArea() {
        return width*height;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }
}
